import mysql.connector

# 连接数据库
conn = mysql.connector.connect(
    host='localhost',
    user='root',
    password='1472580369',
    database='medical_literature_system'
)

cursor = conn.cursor()

# 查询用户信息
cursor.execute("SELECT id, username, password FROM sys_user")
results = cursor.fetchall()

print("所有用户信息:")
for row in results:
    print(f"ID: {row[0]}, 用户名: {row[1]}")
    print(f"密码: {row[2]}")
    # 将密码转换为字符串再计算长度
    password_str = str(row[2])
    print(f"密码长度: {len(password_str)}")

cursor.close()
conn.close()